package com.xie.system.domain.message.dingrobot;

import com.xie.codegen.processor.api.GenCreateRequest;
import com.xie.codegen.processor.api.GenQueryRequest;
import com.xie.codegen.processor.api.GenResponse;
import com.xie.codegen.processor.api.GenUpdateRequest;
import com.xie.codegen.processor.controller.GenController;
import com.xie.codegen.processor.creator.GenCreator;
import com.xie.codegen.processor.creator.IgnoreCreator;
import com.xie.codegen.processor.mapper.GenMapper;
import com.xie.codegen.processor.query.GenQuery;
import com.xie.codegen.processor.repository.GenRepository;
import com.xie.codegen.processor.service.GenService;
import com.xie.codegen.processor.service.GenServiceImpl;
import com.xie.codegen.processor.updater.GenUpdater;
import com.xie.codegen.processor.updater.IgnoreUpdater;
import com.xie.codegen.processor.vo.GenVo;
import com.xie.common.annotation.FieldDesc;
import com.xie.common.constants.ValidStatus;
import com.xie.jpa.converter.ValidStatusConverter;
import com.xie.jpa.support.BaseJpaAggregate;
import lombok.Data;

import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

@GenVo(pkgName = "com.xie.system.domain.message.dingrobot.vo")
@GenCreator(pkgName = "com.xie.system.domain.message.dingrobot.creator")
@GenUpdater(pkgName = "com.xie.system.domain.message.dingrobot.updater")
@GenQuery(pkgName = "com.xie.system.domain.message.dingrobot.query")

@Entity
@Table(name = "ding_robot")
@Data
public class DingRobot extends BaseJpaAggregate {

  @FieldDesc(name = "机器人名称")
  private String name;

  @FieldDesc(name = "机器人编码")
  private String code;

  @FieldDesc(name = "tokenUrl")
  private String tokenUrl;


  @Convert(converter = ValidStatusConverter.class)
  @IgnoreUpdater
  @IgnoreCreator
  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}
